<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="/WEB-INF/tlds/c.tld"%>
<%@ taglib prefix="spring" uri="/WEB-INF/tlds/spring.tld"%>
<c:set var="BasePath" value="${pageContext.request.contextPath}"></c:set>
<c:set var="Plugins" value="${pageContext.request.contextPath}/res/plugins"></c:set>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>财务管理</title>

<link href="${Plugins}/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<link href="${Plugins}/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
<script src="${Plugins}/jquery/jquery-1.8.0.min.js"	type="text/javascript"></script>
<script src="${Plugins}/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
<script type="text/javascript" src="${BasePath}/res/js/ligerCommon.js"></script>
<script src="${Plugins}/datepicker/WdatePicker.js" type="text/javascript"></script>
<style type="text/css">
#searchbar{
   		margin-bottom: 10px;
   		margin-left:15px;
  }
  .navbar {
		height: 20px;
		border-bottom: #E6E6E6 solid 1px;
		line-height: 20px;
	}
  .l-button-search {
		width: 50px;
		margin-left: 10px;
		padding-bottom: 2px;
		display: inline;
}
</style>
</head>

<body style="padding:6px; overflow:hidden;">
<div class="navbar">
		<span>您当前的位置：</span>
		财务管理 &gt; 供应商结算
</div>

<form>

<div id="searchbar"><br>
供应商：<select id="supName" name="supName">
       </select> 
审核状态：<select id="checkState" name="checkState">
       </select>             
结算编号：<input type="text" id="settlementNo" name="settlementNo" value=""/>&nbsp;&nbsp;  
结算日期：<input type="text" id="settlementStartTime" name="settlementStartTime" class="Wdate" size="21" readonly="readonly"
			onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true,autoPickDate:true,maxDate:'#F{$dp.$D(\'settlementEndTime\')||\'2020-10-01\'}'})"> - 
	   <input type="text" id="settlementEndTime" name="settlementEndTime" class="Wdate" size="21" readonly="readonly"
			onFocus="WdatePicker({dateFmt:'yyyy-MM-dd',readOnly:true,autoPickDate:true,minDate:'#F{$dp.$D(\'settlementStartTime\')||\'2013-01-01\'}'})" >
 	<input type="button" id="btnSearch" value="查询" class="l-button-search" />
    <input type="reset" id="btnReset" value="重置" class="l-button-search" />
    <input type="hidden" id="returnOrder" value=""/>
</div>

</form>
<div id="maingrid" style="margin:0; padding:0"></div>
  <div style="display:none;">
  <!-- 展示列表数据  -->
</div>

	<script>
	var basePath='${BasePath}';
    var toolbar;
    var roles = new Array();
    '<c:forEach items="${roleVos}" var="item">';
    	roles.push('${item.roleCode}');
    '</c:forEach>';
    var grid=null;
    function showSettlementInfo(rowindex,o){
	   	 var cNo=grid.getData()[rowindex].settlementNo;
	   	 var url=basePath+'/financing/settlement/toSupplierSettlementDetail.do?settlementNo='+cNo+'&type='+o;
	   	 url+="&pTabid="+WIN_TAB.getSelectedTabItemID();
	   	 window.parent.f_addTab('结算信息', '结算信息',url );
	}
    function toCheckSettlementInfo(rowindex) {
    	var uid = grid.getData()[rowindex].settlementId;
    	var uno = grid.getData()[rowindex].settlementNo;
    	var w = $.ligerDialog.open({
    				title : '供应商结算审核',
    				url : 'toCheckSupplierSettlement.do?settlementId=' + uid+'&settlementNo='+uno,
    				height : 350,
    				width : 500,
    				isResize : false,
    				isDrag : false
    			});
    	w.show();
    }
	/*  var basePath='${BasePath}';
    var grid = null;
      	
    $(function () {
    	 // 重置
        $("#btnReset").click(function(){
    		$('#searchbar :input').not(':submit, :button, :reset').val('').removeAttr('checked').removeAttr('selected');
    	});
    	
        grid = $("#maingrid").ligerGrid({
            columns: [
            { display: '商品编号', name: 'commoNo'},
            { display: '商品名称', name: 'commoName'},
            { display: '分类名称', name: 'catName'},
            { display: '品牌名称', name: 'brandName'},
            { display: '商品类型', name: 'commoType',render:function(rowdata,rowindex,value){
            	var text=null;
            	switch(value){
            	case 0:
            		text="商品";
            		break;
            	case 1:
            		text="赠品";
            		break;
            	case 2:
            		text="免费货";
            		break;
                default:
                	break;
            	}
            	return text;
            }},
            { display: '创建时间', name: 'createTime', width:'15%'},
            { display: '审核状态', name: 'checkState',render:function(rowdata,rowindex,value){
            	var text=null;
            	switch(value){
            	case 0:
            		text="未审核";
            		break;
            	case 1:
            		text="已审核";
            		break;
            	case 2:
            		text="已拒绝";
            		break;
                default:
                	break;
            	}
            	return text;
            }},
            { display: '操作',width:'20%', isSort: false, render: function (rowdata, rowindex, value){
            	var h = "<a href='javascript:showCommodityInfo(" + rowindex + ",1)'>商品信息</a> ";
               	var GOOD_PERSON = "";	//商品专员
               	var GOODS_SUPERVISOR = "";  //商品主管
               	
            	for ( var i in roles) {
               		if(roles[i] == 'GOOD_PERSON'){
               			GOOD_PERSON = "GOOD_PERSON";
               		}
               		if(roles[i] == 'GOODS_SUPERVISOR'){
               			GOODS_SUPERVISOR = "GOODS_SUPERVISOR";
               		}
        		}
            	
             	if(GOOD_PERSON == 'GOOD_PERSON'){
             		var css = "";
             		if(rowdata.checkState == 1) css = "style='color: gray;'";
             		
             		h += "<a href='javascript:setCommodityInfo(" + rowindex + ",2)' "+css+">设置供应商</a> ";
             	    if(rowdata.checkState != 1){
                    	h += "<a href='javascript:updateCommodity(" + rowindex + ")' >修改</a> ";
                    }
                     
                    h += "<a href='javascript:delCommodity(" + rowindex + ")' "+css+">删除</a> ";
				}
            	
            
                return h;
            	}
            }
            ], 
            pageSize:30,
            width: '100%',
            height: '100%',
            dataType: 'server', 
            dataAction: 'server',
            pagesizeParmName: 'pageSize',
            parms: [
					{name: "commoName", value:$("#commoName").val()},
					{name: "commoNo", value:$("#commoNo").val()},
					{name: "checkState", value:$("#checkState").val()},
					{name: "prodNo", value:"${commodity.prodNo}"},
					{name: "createStartDate", value:"${commodity.createStartDate}"},
					{name: "createEndDate", value:"${commodity.createEndDate}"}
                    ],
			url: "aJaxPageCommodityList.do",
			toolbar: toolbar
        });
    });
    var toolbar;
    var roles = new Array();
    '<c:forEach items="${roleVos}" var="item">';
    roles.push('${item.roleCode}');
    '</c:forEach>';
    
    var rpm = 0;
	if (roles.length > 0) {
		var ex = [];
		var add = [];
		var items = [];
		for(var i=0; i<roles.length; i++) {
    		if (roles[i] == 'GOOD_PERSON') {
    			add = [{ text: "新增商品",id:"add", click: addCommodity, icon: "add"},{ line: true }];
    		}
    		if (roles[i] == 'GOODS_SUPERVISOR' || roles[i] == 'FINANCIAL_PRINCIPAL') {
    			ex = [{text: '导出EXCEL', click: doExportExcel, icon: "print"},{ line: true }];
    		}
    	}
		items = items.concat(ex);
		items = items.concat(add);
		toolbar = {items : items};
	}
    //导出商品信息
    function doExportExcel() {
    	var commoNo=$("#commoNo").val();
    	var commoName=$("#commoName").val();
    	var checkState=$("#checkState").val();
    	var prodNo=$("#prodNo").val();
    	var createStartDate=$("#createStartDate").val();
    	var createEndDate=$("#createEndDate").val();
    	
    	var params = '?commoNo='+commoNo+'&commoName='+commoName+'&checkState='+checkState
    			+'&prodNo='+prodNo+'&createStartDate='+createStartDate+'&createEndDate='+createEndDate;
    	if(commoNo == "" && commoName == "" && prodNo == "" && createStartDate == "" && createEndDate == ""){
    		$.ligerDialog.warn("导出商品，查询条件不能为空");
    	}else{
    		var url = basePath+'/product/commoditymgt/doExportExcel.do'+encodeURI(encodeURI(params));
			window.location.href = url;
    	}
	}
    
    //添加商品信息
    function addCommodity(){
    	var url=basePath+'/product/commoditymgt/to_add_commo.do';
    	url+="?pTabid="+WIN_TAB.getSelectedTabItemID();
    	window.parent.f_addTab(new Date().getTime(),'新增商品',url);
    }
    
 	//修改商品信息
    function updateCommodity(rowindex){
    	var commoNo=grid.getData()[rowindex].commoNo;
    	var url=basePath+'/product/commoditymgt/to_update_commo.do?commoNo='+commoNo;
    	url+="&pTabid="+WIN_TAB.getSelectedTabItemID();
    	window.parent.f_addTab(new Date().getTime(),'修改商品',url);
    }
    
    function showCommodityInfo(rowindex,o) {
    	 var cNo=grid.getData()[rowindex].commoNo;
    	 var url=basePath+'/product/commoditymgt/showCommodityInfo.do?commoNo='+cNo+'&type='+o;
    	 url+="&pTabid="+WIN_TAB.getSelectedTabItemID();
    	 window.parent.f_addTab(new Date().getTime(), '商品信息',url );
    }
    
    function setCommodityInfo(rowindex,o) {
	   	var cNo=grid.getData()[rowindex].commoNo;
	   	if(grid.getData()[rowindex].checkState != 1){
	   		var url=basePath+'/product/commoditymgt/showCommodityInfo.do?commoNo='+cNo+'&type='+o;
			url+="&pTabid="+WIN_TAB.getSelectedTabItemID();
		   	window.parent.f_addTab(new Date().getTime(), '设置供应商',url );	
	   	}
	   	 
   	}
    
    
    function detailCommodity(rowindex){
    	 var cNo=grid.getData()[rowindex].cNo;
    	 var url=basePath+'/product/productmgt/detail_commodity.do?cNo='+cNo;
    	 url+="&pTabid="+WIN_TAB.getSelectedTabItemID();
    	 window.parent.f_addTab(new Date().getTime(), '商品详细',url );
    	 
    }
    
    function delCommodity(rowindex){
   		var cNo=grid.getData()[rowindex].commoNo;
	   	var url=basePath+'/product/commoditymgt/deleteCommodity.do?commoNo='+cNo;
	   	url+="&pTabid="+WIN_TAB.getSelectedTabItemID();
	   	window.parent.f_addTab(new Date().getTime(), '删除',url );
   }
    
    
    function delCommodity(rowindex){
    	if(grid.getData()[rowindex].checkState != 1){
		   	$.ligerDialog.confirm('确定删除', function (yes) { if(yes){
		    	var cNo = grid.getData()[rowindex].commoNo;
		    	$.ajax({
			   		 type:'POST',
			   		 url:basePath+"/product/commoditymgt/deleteCommodity.do",
			   	     data:{"commoNo":cNo},
			   		 success : function(data){
			   			 if(data=="check"){
			   				var s=window.parent.$.ligerDialog.error("该商品已通过审核，不能删除","提示",function(item, Dialog, index) {
				          		window.location.href = basePath+'/product/commoditymgt/toPageCommodityList.do';
				          		});
				          		$(s.dialog.winbtns).remove();
			   			 }else if(data == 'success'){
					          window.parent.f_tip('删除成功');
					    	  reload_cur_tab();
			   			
			   		     }else if(data == 'fail'){
			          		window.parent.f_tip('删除失败');
		    				reload_cur_tab();
			   		     }
			   	   	}
		   		});
		   	};});
    	}
    } */
    </script>
	
</body>
</html>

<script type="text/javascript" src="${BasePath}/res/js/financing/supplierSettlement.js"></script>
